package com.zpyr.mvc.vo;

public class Carc_info {
	private String info_seq;
	private String name;
	private String description;
	private String detail_desc;
	private String phone1;
	private String phone2;
	private String phone3;
	private String open_time;
	private String close_time;
	private String grade_total_point;
	private String grade_total_count;
	private String lat;
	private String lng;
	private String addr_sido;
	private String addr_gugun;
	private String addr_dong;
	private String addr;
	private String distance;
	private String category1;
	private String category2;
	
	public String getCategory1() {
		return category1;
	}

	public void setCategory1(String category1) {
		this.category1 = category1;
	}

	public String getCategory2() {
		return category2;
	}

	public void setCategory2(String category2) {
		this.category2 = category2;
	}

	public String getDistance() {
		return distance;
	}
	
	public String getStrDistance() {
		try {
			return Integer.parseInt(distance) >= 1000 ? (Integer.parseInt(distance) / 1000 + "km") : (distance + "m");
		}
		catch(NumberFormatException e) {
			return "0m";
		}
	}

	public void setDistance(String distance) {
		this.distance = distance;
	}

	public int getIgrade_total_point() {
		try {
			return Integer.parseInt( getGrade_total_point() );
		}
		catch(Exception e) {
			return 0;
		}
	}
	
	public int getIgrade_total_count() {
		try {
			return Integer.parseInt( getGrade_total_count() );
		}
		catch(Exception e) {
			return 0;
		}
	}
	
	public String getLat() {
		return lat;
	}
	public void setLat(String lat) {
		this.lat = lat;
	}
	public String getLng() {
		return lng;
	}
	public void setLng(String lng) {
		this.lng = lng;
	}
	public String getAddr_sido() {
		return addr_sido;
	}
	public void setAddr_sido(String addr_sido) {
		this.addr_sido = addr_sido;
	}
	public String getAddr_gugun() {
		return addr_gugun;
	}
	public void setAddr_gugun(String addr_gugun) {
		this.addr_gugun = addr_gugun;
	}
	public String getAddr_dong() {
		return addr_dong;
	}
	public void setAddr_dong(String addr_dong) {
		this.addr_dong = addr_dong;
	}
	public String getAddr() {
		return addr;
	}
	public void setAddr(String addr) {
		this.addr = addr;
	}
	public String getInfo_seq() {
		return info_seq;
	}
	public void setInfo_seq(String info_seq) {
		this.info_seq = info_seq;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getDetail_desc() {
		return detail_desc;
	}
	public void setDetail_desc(String detail_desc) {
		this.detail_desc = detail_desc;
	}
	public String getOpen_time() {
		return open_time;
	}
	public void setOpen_time(String open_time) {
		this.open_time = open_time;
	}
	public String getClose_time() {
		return close_time;
	}
	public void setClose_time(String close_time) {
		this.close_time = close_time;
	}
	public String getGrade_total_point() {
		return grade_total_point;
	}
	public void setGrade_total_point(String grade_total_point) {
		this.grade_total_point = grade_total_point;
	}
	public String getGrade_total_count() {
		return grade_total_count;
	}
	public void setGrade_total_count(String grade_total_count) {
		this.grade_total_count = grade_total_count;
	}
	public double getAvgGrade() {
		try {
			return ( getIgrade_total_point() * 100 / getIgrade_total_count() ) / 100.0;
		}
		catch(Exception e) {
			return 0;
		}
	}
	public String getPhone1() {
		return phone1;
	}
	public void setPhone1(String phone1) {
		this.phone1 = phone1;
	}
	public String getPhone2() {
		return phone2;
	}
	public void setPhone2(String phone2) {
		this.phone2 = phone2;
	}
	public String getPhone3() {
		return phone3;
	}
	public void setPhone3(String phone3) {
		this.phone3 = phone3;
	}
	
	public String getPhone() {
		return getPhone("-");
	}
	
	public String getPhone(String delimeter) {
		if( getPhone1() == null || getPhone2() == null || getPhone3() == null ) return "";
		return getPhone1() + delimeter + getPhone2() + delimeter + getPhone3();
	}
	
	public String getWorkTime() {
		return getWorkTime(" ~ ");
	}

	public String getWorkTime(String delimeter) {
		return getOpen_time(":") + delimeter + getClose_time(":");
	}
	
	public String getOpen_time(String delimeter) {
		String src = getOpen_time();
		if( src == null || src.length() != 4 ) {
			return "";
		}
		
		return src.substring(0,2) + delimeter + src.substring(2,4);
	}
	
	public String getClose_time(String delimeter) {
		String src = getClose_time();
		if( src == null || src.length() != 4 ) {
			return "";
		}
		
		return src.substring(0,2) + delimeter + src.substring(2,4);
	}
}
